#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main(){
    cin>>n;
    map<int,int> mp1,mp0;
    while(n--){
        int c,p;
        cin>>c>>p;
        if (c){
            mp1[p]++;
        }else{
            mp0[p]++;
        }
    }
    int f=1;
    cout<<mp0[1]<<" "<<mp0[2]<<" "<<mp0[3]<<endl;
    cout<<mp1[1]<<" "<<mp1[2]<<" "<<mp1[3]<<endl;
    for (int i=1;i<=3;i++){
        if (mp1[i]>mp0[i]){
            f=0;
            break;
        }else if (mp1[i]<mp0[i]){
            break;
        }
    }
    if (f){
        cout<<"The first win!\n";
    }
    else{
        cout<<"The second win!\n";
    }
    return 0;
}

